
var ajaxUrl = require('../../utils/url.js');
var app = getApp()
Page({
  data: {
    imgUrls: [     
        ],
        indicatorDots: true,
        autoplay: true,
        interval: 3000,
        duration: 1000,
        page:1,
        postsList:[
          
        ],
        hidden:false
  },
  
  onLoad: function () {
    var that = this;
    var my_password = "isearch5.Cs.swust123";
    var userName = "admin";
    var authcode = "1419";
    var password = ajaxUrl.hex_md5(my_password);
    // //ajax请求数据
    // wx.request({
    //   method:"POST",
    //   url: ajaxUrl.ajaxUrl() + "/handler/user/login",
    //   data: {
    //     "userName": userName,
    //     "password": password,
    //     "authcode": authcode,
    //   },
    //   header: {
    //     'Content-Type': 'application/json'
    //   },
    //   success: function(res) {
    //     console.log(res);
    //   }
    // })

    that.fetchImgListDate();
   // console.log(that.data.postsList)
  },
  
  //拉到下一页
  lower:function(e){
    var self = this;
    self.setData({
      page: self.data.page + 1
    });
    
    self.fetchImgListDate({page: self.data.page});
  },
 


 
  fetchImgListDate:function(data){
    var self = this;
    self.setData({
      hidden: false
    });
      if (!data) data = {};
      if (!data.page) data.page = 1;
      if (data.page === 1) {
        self.setData({
          postsList: []
        });
      }
      wx.request({
          method:"GET",
          url:ajaxUrl.ajaxUrl()+"?method=index.getChoicenessList",
          data: {
              "fromPageId":0,
              "pageSize":10,
              "viewUserId":'',
              "page":self.data.page
          },
          header: {
          'Content-Type': 'application/json'
          },
          success: function(res) {
            //console.log(res)
             // var contentObj = [];
               if(res.data.result == 0){
                
                  for(var i in res.data.data.result){
                    self.data.postsList.push({
                        imgUrl: res.data.data.result[i].image+"?imageMogr/v2/auto-orient/thumbnail/750x/quality/80/",
                        userId:res.data.data.result[i].userId,
                        suitId:res.data.data.result[i].suitId
                      });
                  }
               }
               self.setData({
                 postsList:self.data.postsList
               })
              //   self.data.postsList = contentObj
               setTimeout(function () {
                  self.setData({
                    hidden: true
                  });
              }, 300);
          }
      })
      
  }


 
})
